package com.zmc.third.infrastructure.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zmc.common.utils.PageUtils;
import com.zmc.common.utils.Query;

import com.zmc.third.infrastructure.dao.LogisticsInfoDao;
import com.zmc.third.infrastructure.entity.LogisticsInfoEntity;
import com.zmc.third.infrastructure.service.LogisticsInfoService;


/**
 * @author zmc
 */
@Service("logisticsInfoService")
public class LogisticsInfoServiceImpl extends ServiceImpl<LogisticsInfoDao, LogisticsInfoEntity> implements LogisticsInfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<LogisticsInfoEntity> page = this.page(
                new Query<LogisticsInfoEntity>().getPage(params),
                new QueryWrapper<LogisticsInfoEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public LogisticsInfoEntity getByOrderSn(String orderSn) {
        LambdaQueryWrapper<LogisticsInfoEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(LogisticsInfoEntity::getOrderSn, orderSn).orderByDesc(LogisticsInfoEntity::getCreateTime).last(" limit 1");
        return getOne(wrapper);
    }

}